package com.nbsaas.boot.project.data.entity;

import com.nbsaas.boot.code.annotation.FieldConvert;
import com.nbsaas.boot.code.annotation.FieldName;
import com.nbsaas.boot.code.annotation.FormAnnotation;
import com.nbsaas.boot.jpa.data.entity.CatalogEntity;
import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.Comment;

import java.io.Serializable;


@EqualsAndHashCode(callSuper = true)
@Comment("项目分类")
@FormAnnotation(model = "项目分类")
@Data
@Entity
@Table(name = "nb_project_catalog")
public class ProjectCatalog extends CatalogEntity {


    @FieldName
    @FieldConvert
    @ManyToOne(fetch = FetchType.LAZY)
    private ProjectCatalog parent;

    @Column(length = 20)
    @Comment("颜色")
    private String color;


    @Override
    public Serializable getParentId() {
        if (parent != null) {
            return parent.getId();
        }
        return null;
    }
}
